//
//  MZYnewsTableViewCell.m
//  WristWatch
//
//  Created by dllo on 15/10/29.
//  Copyright (c) 2015年 dllo. All rights reserved.
//

#import "MZYnewsTableViewCell.h"

#define WIDTH self.contentView.frame.size.width
#define HEIGHT self.contentView.frame.size.height
@implementation MZYnewsTableViewCell


- (void)dealloc {
    [_titleLabel release];
    [_timeLabel release];
    [_nameLabel release];
    [_titleImageView release];
    
    [super dealloc];
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self createView];
    }
    return self;
}

- (void)createView {
    self.titleLabel = [[UILabel alloc] init];
    [self.contentView addSubview:self.titleLabel];
    self.titleLabel.numberOfLines = 0;
    [_titleLabel release];
    
    self.timeLabel = [[UILabel alloc] init];
    [self.contentView addSubview:self.timeLabel];
    self.timeLabel.textColor = [UIColor grayColor];
    [_timeLabel release];
    
    
    self.titleImageView = [[UIImageView alloc] init];
    [self.contentView addSubview:self.titleImageView];
    [_titleImageView release];
    
}

- (void)layoutSubviews {
    [super layoutSubviews];
    NSDictionary *dic = [NSDictionary dictionaryWithObjectsAndKeys:[UIFont systemFontOfSize:18], NSFontAttributeName, nil];
    CGRect rect = [self.titleLabel.text boundingRectWithSize:CGSizeMake(WIDTH / 1.25 - 15, 0) options:NSStringDrawingUsesLineFragmentOrigin attributes:dic context:nil];
    self.titleLabel.frame = CGRectMake(5, HEIGHT / 12, WIDTH / 1.25 - 15, rect.size.height);
    self.titleLabel.font = [UIFont boldSystemFontOfSize:18.0];
    self.timeLabel.frame = CGRectMake(5, rect.size.height + 10, WIDTH / 2.5, HEIGHT / 5 - 10);
    self.titleImageView.frame = CGRectMake(WIDTH / 1.25 - 10, HEIGHT / 12, WIDTH / 5 - 5, HEIGHT / 2 + 10);
    
}


- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
